<template>
  <div>
    <div class="userTitle">
      谁可以提交
    </div>
    <org-items v-model="select" @selectOrg="selectOrg"/>
    <!--    选择部门/用户-->
    <org-picker title="请选择可发起本审批的人员/部门" multiple ref="orgPicker" :selected="select" :type="orgPickerType" @ok="selected"/>
  </div>
</template>

<script>
import OrgPicker from "@/components/common/OrgPicker";
import OrgItems from "../OrgItems";

export default {
  name: "RootConfig",
  components: {OrgPicker, OrgItems},
  props: {
    config: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      showOrgSelect: false,
      orgPickerType: 'org',
    }
  },
  computed: {
    select() {
      console.log('select-computed', this.config)
      return this.config.assignedUser
    }
  },
  methods: {
    selectOrg() {
      this.$refs.orgPicker.show()
    },
    selected(select) {
      this.select.length = 0
      select.forEach(val => this.select.push(val))
    },
    removeOrgItem(index) {
      this.select.splice(index, 1)
    }
  }
}
</script>

<style lang="less" scoped>
.desc {
  font-size: small;
  color: #8c8c8c;
}

.org-item {
  margin: 5px;
}

</style>
